import request from '@/utils/request.js'

// 获取预约详情
export function getBookingDetail(id) {
  return request({
    url: `bookings/info`,
    method: 'GET',
	params: {id:id}
  })
}

// 创建预约
export function createBooking(data) {
  return request({
    url: 'bookings',
    method: 'POST',
    data
  })
}

// 取消预约
export function cancelBooking(id) {
  return request({
    url: `bookings/${id}/cancel`,
    method: 'PUT'
  })
}

// 获取用户预约列表
export function getUserBookings(params) {
  return request({
    url: 'bookings',
    method: 'GET',
    params
  })
}

// 评价教师
export function evaluateTeacher(data) {
  return request({
    url: 'teacher/evaluate',
    method: 'POST',
    data
  })
}

// 获取省份列表
export function getProvinces() {
  return request({
    url: 'area/provinces',
    method: 'GET'
  })
}

// 获取城市列表
export function getCities(provinceCode) {
  return request({
    url: 'area/cities',
    method: 'GET',
    params: { provinceCode }
  })
}

// 获取区县列表
export function getDistricts(cityCode) {
  return request({
    url: 'area/districts',
    method: 'GET',
    params: { cityCode }
  })
}


// 导出bookingApi对象
export const bookingApi = {
  getBookingDetail,
  createBooking,
  cancelBooking,
  getUserBookings,
  evaluateTeacher,
  getProvinces,
  getCities,
  getDistricts
}